#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> s(100001);
vector<int> sex(100001, 0);
bool bfs(int a, int b) {
    queue<int> q;
    vector<bool> visited(100001, false);
    q.push(a);
    visited[a] = true;
    int count = 0;
    while (!q.empty())
    {
        int size = q.size();
        if (count >= 4) break;
        for (int i = 0; i < size; ++i)
        {
            int current = q.front();
            q.pop();
            for (const auto& j : s[current])
            {
                q.push(j);
                visited[j] = true;
            }

        }
        count++;
    }
    count = 0;
    while (q.size())
        q.pop();
    q.push(b);
    visited[b] = true;
    while (!q.empty())
    {
        int size = q.size();
        if (count >= 4) break;
        for (int i = 0; i < size; ++i)
        {
            int current = q.front();
            q.pop();
            for (const auto& j : s[current])
            {
                q.push(j);
                if (visited[j])
                {
                    visited[i] = true;
                    return false;
                }
            }

        }
        count++;
    }
    return true;

}
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int number, male, female;
        char sexx;
        cin >> number >> sexx >> male >> female;
        if (sexx == 'M') sex[number] = 1;
        else if (sexx == 'F') sex[number] = 2;
        if (male != -1)
        {
            s[number].push_back(male);
            sex[male] = 1;
        }
        if (female != -1)
        {
            s[number].push_back(female);
            sex[female] = 2;
        }

    }
    int m;
    cin >> m;
    while (m--) {
        int a, b;
        cin >> a >> b;
        if (sex[a] == sex[b]) {
            cout << "Never Mind" << endl;
            continue;
        }
        bool flag = bfs(a, b);
        if (flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

}
